package com.example.chapter3.dao;

import com.example.chapter3.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

//添加Mapper注解，让UserDao接口，成为Mybatis映射器接口
@Mapper
public interface UserDao {
    @Results(id = "userMap",value = {
            @Result(property = "name",column = "username"),
            @Result(property = "sex",column = "sex"),
            @Result(property = "password",column = "password")
    })
    @Select("select * from user where username = #{username} and password = #{password}")
    User getUserByName(@Param("username") String name, String password);

    @Insert("insert into user(username,password,sex) values (#{username},#{password},#{sex})")
    int creatUser(User user);
}
